<?php

/*
 * Created on Dec 7, 2013
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class Lookup_model extends CI_Model {

	public function __construct() {
		$this->load->database();
	}
	
//	public function lookup_insert($arr){
//		$this->db->insert('tbl_lookup', $arr);
//	}
//	
//	public function lookup_update($id, $arr){
//		$this->db-where('id', $id);
//		$this->db->update('tbl_lookup', $arr);
//	}
//	
//	public function lookup_delete($id){
//		$this->db->where('id', $id);
//		$this->db->delete('tbl_lookup');
//	}
//	
//	public function get_lookup($code, $type = 1){
//		$this->db->where('l_code', $code);
//		$this->db->where('l_type', $type);
//		return $this->db->get('tbl_lookup')->row_array();
//	}
//	
//	public function get_last_game_code($others){
//		$sql = "select * from (select cast(substring(l_code, 6) as SIGNED) l_code, 'modify' operate from tbl_lookup where l_type=1 and l_value=? union all select (max(cast(substring(l_code, 6) as SIGNED)) + 1) code, 'create' operate from tbl_lookup) t limit 0, 1";
//		$query = $this->db->query($sql, array($others));
//		$res = array('l_code'=>'game.1', 'operate'=>'create');
//		if($query->num_rows() > 0){
//			$row = $query->row();
//			$res = array('l_code'=>'game.'.$row->l_code, 'operate'=>$row->operate);
//		}
//		return $res;
//	}
//	
//	public function list_lookup($type = '', $sort = false, $asc = true, $limit = false, $offset = false){
//		($type)?$this->db->where('l_type', $type):'';
//		if($sort){
//			$this->db->order_by($sort, $asc?'asc':'desc'); 
//		}
//		if($limit && $offset){
//			$this->db->limit($limit, $offset);
//		}
//		$query = $this->db->get('tbl_lookup');
//		return $query->result_array();
//	}
//	
//	public function count_lookup($type = ''){
//		($type)?$this->db->where('l_type', $type):'';
//		return $this->db->count_all_results('lookup');
//	}
}


